package com.fxd.kafka.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @author fuxudong
 * @date 2022/08/02
 */
@Slf4j
@Component
public class EasyConsumer {

    // 服务刚启动时，监听加载需要时间，消费监听
    @KafkaListener(topics = {"DEMO_TOPIC"}, groupId = "DEMO_GROUP")
    public void onMessage1(ConsumerRecord<?, ?> record) {
        // 消费的哪个topic、partition的消息,打印出消息内容
        log.info("简单消费：" + record.topic() + "-" + record.partition() + "-" + record.value());
    }

}
